import dt from '@dt/dt'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'
import organizationOpt from '@/biz/option/organization.js'

function status(name) {
  return name === 'templateApprovalManager' ? [{
    key: 'state',
    title: '状态',
    placeholder: '全部',
    select: {
      options: dt.dictInfo().processAuditStatus
    }
  }] : []
}

function options(name) {
  return [
    organizationOpt.create(),
    houseOpt.create({
      to: (info) => {
        return {
          housesId: info.housesId
        }
      }
    }),
    {
      key: 'templateType',
      title: '模板类型',
      placeholder: '全部',
      select: {
        options: dt.dictInfo().bonusTemplateTypeTwo
      },
      data: {
        from: (info) => {
          if (info.templateType) {
            let data = dt.dictInfo().bonusTemplateTypeTwo
            return data.find(i => i.value == info.templateType).key
          }
          return null
        },
        to: (v) => {
          return {
            templateType: v ? v.label : ''
          }
        }
      }
    },
    ...status(name)
  ]
}

export default {
  options
}